package com.sixth.controller;

import com.sixth.entity.Menu;
import com.sixth.service.MenuService;
import com.sixth.util.CommonResult;
import com.sixth.util.TableLayUi;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * @program: carrent
 * @description:
 * @author: 高振杨
 * @create: 2022-01-12 11:41
 **/

@RestController
@RequestMapping("menu")
public class MenuController {

    @Autowired
    private MenuService menuService;
    //主页左侧侧边栏
    @RequestMapping("/children")
    public CommonResult Findchildren(){
        return menuService.findByUserRid();
    }

    //查询
    @RequestMapping("findAlling")
    public CommonResult findAlling(){
        return menuService.findAlling();
    }



    @RequestMapping("findRoleMenuId")
    public CommonResult findRoleMenuId(Integer roleid){
        System.out.println(roleid);
        return menuService.findRoleMenuId(roleid);
    }

    //修改权限
    @RequestMapping("updatePermission")
    public CommonResult updatePermission(Integer roleid,String midArr){
        String[] mids = midArr.split(",");
        return menuService.updatePermission(roleid,mids);
    }

    //修改
    @RequestMapping("updateMenu")
    public CommonResult updateMenu(Menu menu){
        return menuService.updateMenu(menu);
    }
    //添加菜单
    @RequestMapping("addMenu")
    public CommonResult addMenu(Menu menu) {
        System.out.println(menu);
        return menuService.addMenu(menu);
    }

    @RequestMapping("checkMenuHasChildren")
    public CommonResult checkMenuHasChildren(Integer id){
        return menuService.queryMenuByPid(id);
    }

    //树形菜单
    @RequestMapping("treeMenu")
    public CommonResult treeMenu(){
        return menuService.findAllMenu();
    }

    //查全部
    @RequestMapping("findAll")
    public TableLayUi findAll(int page, int limit, String title){
        System.out.println("到这里输出title"+title);
        return menuService.findAll(page, limit, title);
    }
}
